import Vue from 'vue'
import App from './App.vue'
import router from './router';

Vue.config.productionTip = false


let instance = null;  // vue实例对象

/**开始接入微前端*/
function render() {
  instance = new Vue({
    router,
    // store,
    render: h => h(App)
  }).$mount('#app-vue')
}

// 非微前端引入情况下直接渲染
if(!window.__POWERED_BY_QIANKUN__) {
  render()
}

// 微前端环境下执行：
// 暴露vue2自定义的生命周期给主应用或者微前端框架
// 通过window.vue可访问到下面三个函数
export const bootstrap = async () => {
  console.log("开始加载")
}

export const mount = async () => {
  render()
  console.log("渲染成功")
}

export const unmount = async () => {
  console.log("卸载成功==", instance)
}
